package com.itheima.vo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {

    private Integer code=200;
    private Object data;
    private String message;

    public Result(Integer code,Object data) {
        this.code = code;
        this.data=data;
    }

    public Result(Object data, String message) {
        this.data = data;
        this.message = message;
    }

    public Result(Integer code) {
        this.code = code;
    }

    public static Result success(Object data){
        Result result=new Result();
        result.setCode(200);
        result.setMessage("操作成功!");
        result.setData(data);
        return result;
    }
    public static Result error(Object data, String message){
        Result result=new Result();
        result.setCode(401);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result errorMy(String message){
        Result result=new Result();
        result.setCode(500);
        result.setMessage(message);
        result.setData(null);
        return result;
    }
    public static Result errorSys(){
        Result result=new Result();
        result.setCode(500);
        result.setMessage("系统异常,程序员正在维修");
        result.setData(null);
        return result;
    }
}
